#pragma once
#include <string>
#include <map>

class GiteeProvider {
public:
    GiteeProvider(const std::string& access_token = "");
    
    void setAccessToken(const std::string& token) { access_token_ = token; }
    
    // 仓库操作
    bool createRepository(const std::string& name, const std::string& description = "", bool is_public = true);
    bool repositoryExists(const std::string& name);
    bool deleteRepository(const std::string& name);
    
    // 镜像操作
    bool createMirrorRepository(const std::string& name, const std::string& source_url, const std::string& description = "");
    bool syncMirrorRepository(const std::string& name);
    
    // 组织操作
    bool createOrganizationRepository(const std::string& org, const std::string& name, const std::string& description = "");
    bool organizationRepositoryExists(const std::string& org, const std::string& name);
    
    // 工具函数
    static std::string extractRepoNameFromUrl(const std::string& url);
    static std::string extractOrgFromUrl(const std::string& url);

private:
    std::string access_token_;
    std::string base_url_ = "https://gitee.com/api/v5";
    
    bool callAPI(const std::string& endpoint, const std::string& method = "GET", 
                 const std::map<std::string, std::string>& data = {});
    std::string buildQueryString(const std::map<std::string, std::string>& params);
};
